package avicit.tlk.back.demo.my111.api;

import avicit.platform6.core.rest.msg.QueryReqBean;
import avicit.platform6.core.rest.msg.QueryRespBean;
import avicit.platform6.core.rest.msg.ResponseMsg;
import avicit.platform6.core.restclient.RestClient;
import avicit.platform6.core.restclient.RestClientUtils;
import avicit.tlk.back.demo.my111.dto.My111DTO;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;

/**
 * My111API类
 *
 * @author 朱辉云
 * @version 1.0.0
 * @date 2025-06-13 10:23:55
 * @since 1.0.0
 */
@Component
public class My111API {

	/**
	 * 服务编码
	 */
	private static final String SERVICE_CODE = "tlk-back";
	/**
	 *服务路径签字
	 */
	private static final String BASE_PATH = "api/tlk/back/my111";

	@Autowired
	private RestClient restClient;

	/**
	 * 按条件分页查询数据
	 *
	 * @param queryReqBean   查询参数
	 * @return 满足条件的分页数据
	 */
	public QueryRespBean<My111DTO> findListByPage(QueryReqBean<My111DTO> queryReqBean) {
		String url = BASE_PATH + "/find-list-by-page/v1";
		ResponseMsg<QueryRespBean<My111DTO>> responseMsg = restClient.doPost(SERVICE_CODE, url, queryReqBean, new ParameterizedTypeReference<ResponseMsg<QueryRespBean<My111DTO>>>() {});
		return RestClientUtils.getResponseBody(responseMsg);
	}

	/**
	 * 按条件不分页查询数据
	 *
	 * @param queryReqBean   查询参数
	 * @return 满足条件的数据
	 */
	public List<My111DTO> findList(QueryReqBean<My111DTO> queryReqBean) {
		String url = BASE_PATH + "/find-list/v1";
		ResponseMsg<List<My111DTO>> responseMsg = restClient.doPost(SERVICE_CODE, url, queryReqBean, new ParameterizedTypeReference<ResponseMsg<List<My111DTO>>>() {});
		return RestClientUtils.getResponseBody(responseMsg);
	}

	/**
	 * 根据主键查询数据
	 *
	 * @param id   主键
	 * @return 主键查询的数据
	 */
	public My111DTO getById(String id) {
		String url = BASE_PATH + "/get/" + id + "/v1";
		ResponseMsg<My111DTO> responseMsg = restClient.doGet(SERVICE_CODE, url, new ParameterizedTypeReference<ResponseMsg<My111DTO>>() {});
		return RestClientUtils.getResponseBody(responseMsg);
	}

	/**
	 * 保存表单对象
	 *
	 * @param entity   表单数据
	 * @return 主键
	 */
	public String save(My111DTO entity) {
		String url = BASE_PATH + "/save/v1";
		ResponseMsg<String> responseMsg = restClient.doPost(SERVICE_CODE, url, entity, new ParameterizedTypeReference<ResponseMsg<String>>() {});
		return RestClientUtils.getResponseBody(responseMsg);
	}

	/**
	 * 修改部分表单字段
	 *
	 * @param entity   表单数据
	 * @return 受影响的行数
	 */
	public Integer updateSensitive(My111DTO entity) {
		String url = BASE_PATH + "/update-sensitive/v1";
		ResponseMsg<Integer> responseMsg = restClient.doPut(SERVICE_CODE, url, entity, new ParameterizedTypeReference<ResponseMsg<Integer>>() {});
		return RestClientUtils.getResponseBody(responseMsg);
	}

	/**
	 * 修改全部表单字段
	 *
	 * @param entity   表单数据
	 * @return 受影响的行数
	 */
	public Integer updateAll(My111DTO entity) {
		String url = BASE_PATH + "/update-all/v1";
		ResponseMsg<Integer> responseMsg = restClient.doPut(SERVICE_CODE, url, entity, new ParameterizedTypeReference<ResponseMsg<Integer>>() {});
		return RestClientUtils.getResponseBody(responseMsg);
	}

	/**
	 * 按主键单条删除数据
	 *
	 * @param id   主键
	 * @return 受影响的行数
	 */
	public Integer deleteById(String id) {
		String url = BASE_PATH + "/delete-by-id/" + id + "/v1";
		ResponseMsg<Integer> responseMsg = restClient.doDelete(SERVICE_CODE, url, new ParameterizedTypeReference<ResponseMsg<Integer>>() {});
		return RestClientUtils.getResponseBody(responseMsg);
	}

	/**
	 * 主表数据批量删除数据
	 *
	 * @param ids   主键
	 * @return 受影响的行数
	 */
	public Integer deleteByIds(String[] ids) {
		String url = BASE_PATH + "/delete-by-ids/v1";
		ResponseMsg<Integer> responseMsg = restClient.doDelete(SERVICE_CODE, url, ids, new ParameterizedTypeReference<ResponseMsg<Integer>>() {});
		return RestClientUtils.getResponseBody(responseMsg);
	}
}
